package chapter07

import scala.collection.mutable

/**
  * 不可变调用操作符,可变集合调用方法
  * 可变集合之 可变Map
  */
object Test09_MutableMap {

  def main(args: Array[String]): Unit = {
    val map: mutable.Map[String, Int] = mutable.Map("zhang" -> 34, "li" -> 23)
    println(map)
    println(map.getClass)

    map.put("刘备", 88)
    println(map.getOrElse("刘备", 0))
    map.remove("刘备")
    map.+=(("e", 99))
    map += (("f", 991))
    map -= "e"
    println(map)

    // 合并map
    val map2: mutable.Map[String, Int] = mutable.Map("gg" -> 34, "mm" -> 23)
    map ++= map2
    println(map)

  }
}
